
  function sport(ele,obj,fn = ()=>{}) {
    let count = 0;
    for(let key in obj){
        count++;
        const types = key;
        let target = obj[key]; 

        if (types === 'opacity') {
                target *= 100;
        }
        var timer = setInterval(() => {
                var init;
                if (types == 'opacity') {
                    init = window.getComputedStyle(ele)[types] * 100;
                } else {
                    init = parseInt(window.getComputedStyle(ele)[types]);
                }
 
                let duration = (target - init) / 10;

                duration = duration > 0 ? Math.ceil(duration) : Math.floor(duration);
                
                if (init === target) {
                    clearInterval(timer);
                    count--;
                    if(count == 0){
                        
                        fn();
                    }
                } else {
                    if (types === 'opacity') {
                        ele.style[types] = (init + duration) / 100;

                    } else {
                        ele.style[types] = init + duration + 'px';
                    }

                }

            }, 10)
            }

}

export default sport;